//
//  RW_SingleModel.m
//  SleepApp
//
//  Created by MAC on 2021/3/25.
//  Copyright © 2021 RiceWang. All rights reserved.
//

#import "RW_SingleModel.h"

@implementation RW_SingleModel
+ (NSDictionary *)modelContainerPropertyGenericClass {
    return @{
        @"list":RW_SongModel.class
        
    };
}
//返回一个 Dict，将 Model 属性名对映射到 JSON 的 Key。
//+ (NSDictionary *)modelCustomPropertyMapper {
//    return @{@"ID" : @"id",};
//}


#pragma mark -- 网络请求

/** 所有歌单列表歌单获取 */
+ (FBLPromise<NSArray<RW_SingleModel *> *> *)getSingleList {
    return [FBLPromise async:^(FBLPromiseFulfillBlock  _Nonnull fulfill, FBLPromiseRejectBlock  _Nonnull reject) {
        NSLog(@"推荐分类-好书推荐类别获取");
        [HTTPRequestTool getWithUrl:getSingleListUrl refreshCache:NO params:nil success:^(id response) {
            HTTPLogicalModel *model = [HTTPLogicalModel yy_modelWithJSON:response];
            if (!model.success){
                reject([NSError errorWithDomain:model.message code:model.code userInfo:nil]);
                return;
            }
            NSArray<RW_SingleModel *> *m = [NSArray yy_modelArrayWithClass:RW_SingleModel.class json:model.data];
            fulfill(m);
        } fail:^(NSError *error) {
            reject(error);
        }];
    }];
}

/** 歌单详情获取 */
+ (FBLPromise<RW_SingleModel *> *)getSingleSongListId:(NSString *)xid {
    return [FBLPromise async:^(FBLPromiseFulfillBlock  _Nonnull fulfill, FBLPromiseRejectBlock  _Nonnull reject) {
        NSLog(@"推荐分类-好书推荐类别获取");
        [HTTPRequestTool getWithUrl:getSingleSongListUrl refreshCache:NO params:@{
                @"xid":xid
        } success:^(id response) {
            HTTPLogicalModel *model = [HTTPLogicalModel yy_modelWithJSON:response];
            if (!model.success){
                reject([NSError errorWithDomain:model.message code:model.code userInfo:nil]);
                return;
            }
            RW_SingleModel *m = [RW_SingleModel yy_modelWithJSON:model.data];
            fulfill(m);
        } fail:^(NSError *error) {
            reject(error);
        }];
    }];
}

@end
